

#include "stdafx.h"
#include "pf_block.h"

#include "pf_graphic.h"

/**
 * @param parent The graphic this block belongs to.
 * @param name The name of the block used as an identifier.
 * @param basePoint Base point (offset) of the block.
 */
PF_Block::PF_Block(PF_Container* parent,
                   const PF_BlockAttribute& d)
        : PF_Document(parent), data(d) {

    pen = PF_Pen(PF_Color(128,128,128), LX_Define::Width01, LX_Define::SolidLine);
}



PF_Block::~PF_Block() {}



PF_Entity* PF_Block::clone() {
    PF_Block* blk = new PF_Block(*this);
    blk->setOwner(isOwner());
    blk->detach();
    blk->initId();
    return blk;
}



PF_LayerList* PF_Block::getLayerList() {
    PF_Graphic* g = getGraphic();
    if (g!=NULL) {
        return g->getLayerList();
    } else {
        return NULL;
    }
}



PF_BlockList* PF_Block::getBlockList() {
    PF_Graphic* g = getGraphic();
    if (g!=NULL) {
        return g->getBlockList();
    } else {
        return NULL;
    }
}


bool PF_Block::save(bool isAutoSave) {
    PF_Graphic* g = getGraphic();
    if (g!=NULL) {
        return g->save(isAutoSave);
    } else {
        return false;
    }
}


bool PF_Block::saveAs(const QString& filename, LX_Define::FormatType type) {
    PF_Graphic* g = getGraphic();
    if (g!=NULL) {
        return g->saveAs(filename, type);
    } else {
        return false;
    }
}



/**
 * Sets the parent documents modified status to 'm'.
 */
void PF_Block::setModified(bool m) {
    PF_Graphic* p = getGraphic();
    if (p) {
        p->setModified(m);
    }
    modified = m;
}
